<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>考试信息表</title>
	<link rel="stylesheet" href="layui/css/layui.css">
	<link rel="stylesheet" href="soulTable.css" media="all"/>
	<script src="layui/layui.js"></script>
	
</head>
<body>
	<h2 align=center>考试信息表</h2>
	<table id="myTable" ></table>
	<script type="text/html" id="toolbar">
		<div><button class="layui-btn layui-btn-sm" lay-event="clearFilter">清除所有筛选条件</button></div>
	</script>
	<!-- 操作条模板 -->
	<%
	 /*判断用户类型*/
	 String usertype = (String)session.getAttribute("usertype");
	 
	 if(usertype==null)
	 {
		 usertype="";
	 }
	 
	
	%>
	<script type="text/html" id="bar">
		<%
		if(usertype.equals("admin"))
		{
		%>
			<a href="exam_modify.html" class="layui-btn layui-btn-xs" lay-event="edit">修改</a>
			<a href="exam_modify.html" class="layui-btn layui-btn-xs" lay-event="edit">安排监考</a>
		<%
		}
		else{
		%>
		<a href="invigilator_apply.jsp" class="layui-btn layui-btn-xs" lay-event="edit">申请</a>
		<%
		}
		%>
	</script>
	<script type="text/javascript" src="layui/layui.js"></script>
	<script>
		layui.config({
		    base: 'ext/',   // 模块目录
		}).extend({                         
		    soulTable: 'soulTable'  // 模块别名
		});
	
		layui.use(['form', 'table','soulTable'], function () {
	   	var table = layui.table,
	  	 soulTable = layui.soulTable;
	   	
	   	
	   	// 后台分页
	   	table.render({
			elem: '#myTable'
		    ,id: 'myTable'
		    //,url: '/examination-management-system/infoservlet'
		    //,url: 'exam_data.jsp'
		    ,url: 'exam_info.json'
		    ,height: 500
		    ,toolbar: '#toolbar'
		    ,page: true
		    ,cols: [[
			  {type: 'checkbox', fixed: 'left'},
			  {field: 'examId', title: '考试编号', width: 100 , filter: true},
		      {field: 'status', title: '考试状态', width: 110, sort: true, filter: true},
		      {field: 'term', title: '学期', width: 150, sort: true, filter: true},
		      {field: 'college', title: '学院', width: 100 , filter: true},
		      {field: 'course', title: '课程名', width: 120,  filter: true},
		      {field: 'classes', title: '考试班级', width: 120, filter: true},
		      {field: 'date', title: '考试日期', width: 110,  filter: true},
		      {field: 'examTime', title: '考试时间', width: 100, filter: false},
		      {field: 'location', title: '考试地点', width: 100, filter: true},
		      {field: 'teacher', title: '监考老师', width: 100, filter: true},
		      {field: 'workload', title: '监考工分', width: 100, filter: true},
		      {field: 'teacherRequire', title: '监考缺少人数', width: 100, filter: true},
		      {title: '操作', width: 220, fixed: 'right', templet: '#bar'}
		    ]]
		    ,done: function () {
		      soulTable.render(this)
		    }
		  });
		  
		  table.on('toolbar(myTable)', function(obj){
		    if (obj.event === 'clearFilter') {
		      // 清除所有筛选条件并重载表格
		      // 参数: tableId
		      soulTable.clearFilter('myTable')
		    }
		  });
		})
	</script>
	
</body>
</html>